<template>
    <div>
        <el-button link type="primary" size="small" @click="AddCG()">
            +添加
          </el-button>
    </div>
    <el-table :data="tableData" style="width: 100%">
      <el-table-column fixed prop="purchaseOrderId" label="序号" width="150" />
      <el-table-column prop="serialNumber" label="采购编码" width="120" />
      <el-table-column prop="orderSubject" label="采购订单主题" width="120" />
      <el-table-column prop="supplierName" label="供应商名称" width="120" />
      <el-table-column prop="purchaseDate" label="采购日期" width="120" />
      <el-table-column prop="remarks" label="物品概要" width="120" />
      <el-table-column prop="purchaseDepartment" label="采购部门" width="120" />
      <el-table-column prop="purchaser" label="采购人员" width="120" />
      <el-table-column prop="totalPriceTax" label="总金额" width="120" />
      <el-table-column prop="exclusiveTaxUnitPrice" label="已付金额" width="120" />
      <el-table-column prop="exclusiveTaxAmount" label="已到票金额" width="120" />
      <el-table-column prop="contactWay" label="审批状态" width="120" />
      <el-table-column prop="deliveryDate" label="交付期限" width="120" />
      <el-table-column prop="taxRate" label="付款状态" width="120" />
      <el-table-column prop="inclusiveTaxUnitPrice" label="入库状态" width="120" />
      <el-table-column prop="purchaseQuantity" label="到票状态" width="120" />
      <el-table-column prop="remarks" label="备注" width="120" />
      
      <el-table-column fixed="right" label="" min-width="120">
        <template #default>
         
        </template>
      </el-table-column>
    </el-table>


    <div class="demonstration">所有数据</div>
    <el-pagination
      v-model:current-page="page.Index"
      v-model:page-size="page.Size"
      :page-sizes="[1, 5, 10, 15]"
      :size="size"
      :disabled="disabled"
      :background="background"
      layout="total, sizes, prev, pager, next, jumper"
      :total="page.TotalCount"
      @size-change="handleSizeChange"
      @current-change="handleCurrentChange"
      prev-text="上一页"
      next-text="下一页"
    />

  </template>
  
  <script lang="ts" setup>
  import { Index } from '@syncfusion/ej2/charts';
import { Size } from '@syncfusion/ej2/svg-base';
import { onMounted, reactive, ref } from 'vue';
import axios from 'axios';
import type { ComponentSize } from 'element-plus'
import router from '@/router';
const apiUrl = import.meta.env.VITE_APP_API_URL;

const currentPage1 = ref(5)
const currentPage2 = ref(5)
const currentPage3 = ref(5)
const currentPage4 = ref(4)
const pageSize2 = ref(100)
const pageSize3 = ref(100)
const pageSize4 = ref(100)
const size = ref<ComponentSize>('default')
const background = ref(false)
const disabled = ref(false)

const handleSizeChange = (val: number) => {
  console.log(`${val} items per page`)
  page.TotalCount=val
  ShowCG();
}
const handleCurrentChange = (val: number) => {
  console.log(`current page: ${val}`)
  page.PageCount=val
  ShowCG();
}

const AddCG=()=>{
    router.push('AddCG')
}


  const page=reactive({
    Index:1,
    Size:15,
    TotalCount:0,
    PageCount:0,
  })

onMounted(()=>{
    ShowCG();
})
  const ShowCG=()=>{
    axios.get(apiUrl+'/T5/Setting/ShowCGXS',{params:page})
    .then(res=>{
        tableData.value=res.data.data
        page.TotalCount=res.data.totalCount
        page.PageCount=res.data.pageCount
    })
  }
  const handleClick = () => {
    console.log('click')
  }
  
  const tableData = ref([])
  </script>
  

  <style scoped>
.demo-pagination-block + .demo-pagination-block {
  margin-top: 10px;
}
.demo-pagination-block .demonstration {
  margin-bottom: 16px;
}
</style>